import {
	defineStore
} from 'pinia';
import {
	reqIsOnlineApi
} from '../../request/modules/chat';

const useChatStore = defineStore('chat', () => {
	let selfAvatar = uni.getStorageSync('avator_url') ||
		'https://profile-avatar.csdnimg.cn/c6a8135e4a5e4999b18ac972692a561f_zuoyueliang.jpg!1';
	return {
		chatHandler(conversationID, avatar, remark, userID) {
			avatar = 'https://profile-avatar.csdnimg.cn/71f6abde7c544e0b8154ed4a646633ed_weixin_56388890.jpg!1';
			uni.navigateTo({
				url: `/TUIKit/components/TUIChat/index?conversationID=${conversationID}&fromAvatar=${avatar}&selfAvatar=${selfAvatar}&remark=${remark}&userID=${userID}`
			});
		},
		async getIsOnline() {
			const res = await reqIsOnlineApi();
			console.log(res);
		}
	}
});

export default useChatStore;